package zl.applet.oldsnakey;
import java.io.Serializable;

//玩家类、可序列化、可排序
public class Player implements Serializable,Comparable<Player>
{
	private static final long serialVersionUID = 1L;
	private String name = "无名氏";   //玩家姓名
	private int score = 0;     //积分

	//封装属性
	public void setName(String name)
	{
		this.name = name;
	}
	public String getName()
	{
		return this.name;
	}

	public void setScore(int score)
	{
		this.score = score;
	}
	public int getScore()
	{
		return this.score;
	}
	//带参构造、为属性实例化
	public Player(String name,int score)
	{
		if(name != null)
			this.name = name;
		this.score = score;
	}
	
	//实现Comparable接口的排序方法
	public int compareTo(Player p)
	{
		if(this.score < p.getScore())
			return 1;
		else
			return 0;
	}
}